using UnityEngine;
using GameFramework;
using UnityGameFramework.Runtime;

namespace LS.UGFUnits
{
    public partial class Utility
    {
        public class GFVariable
        {
            public static Variable CreateVariable(object value)
            {
                Variable variable = null;
                if (value is int)
                {
                    variable = ReferencePool.Acquire<VarInt32>();
                    variable.SetValue(value);
                    
                }
                else if (value is short)
                {
                    variable = ReferencePool.Acquire<VarInt16>();
                    variable.SetValue(value);
                }
                else if (value is long)
                {
                    variable = ReferencePool.Acquire<VarInt64>();
                    variable.SetValue(value);
                }
                else if (value is uint)
                {
                    variable = ReferencePool.Acquire<VarUInt32>();
                    variable.SetValue(value);
                }
                else if (value is ushort)
                {
                    variable = ReferencePool.Acquire<VarUInt16>();
                    variable.SetValue(value);
                }
                else if (value is ulong)
                {
                    variable = ReferencePool.Acquire<VarUInt64>();
                    variable.SetValue(value);
                }
                else if (value is float)
                {
                    variable = ReferencePool.Acquire<VarSingle>();
                    variable.SetValue(value);
                }
                else if (value is double)
                {
                    variable = ReferencePool.Acquire<VarDouble>();
                    variable.SetValue(value);
                }
                else if (value is decimal)
                {
                    variable = ReferencePool.Acquire<VarDecimal>();
                    variable.SetValue(value);
                }
                else if (value is byte)
                {
                    variable = ReferencePool.Acquire<VarByte>();
                    variable.SetValue(value);
                }
                else if (value is sbyte)
                {
                    variable = ReferencePool.Acquire<VarSByte>();
                    variable.SetValue(value);
                }
                else if (value is bool)
                {
                    variable = ReferencePool.Acquire<VarBoolean>();
                    variable.SetValue(value);
                }
                else if (value is char)
                {
                    variable = ReferencePool.Acquire<VarChar>();
                    variable.SetValue(value);
                }
                else if (value is string)
                {
                    variable = ReferencePool.Acquire<VarString>();
                    variable.SetValue(value);
                }
                else if (value is Vector2)
                {
                    variable = ReferencePool.Acquire<VarVector2>();
                    variable.SetValue(value);
                }
                else if (value is Vector3)
                {
                    variable = ReferencePool.Acquire<VarVector3>();
                    variable.SetValue(value);
                }
                else if (value is Vector4)
                {
                    variable = ReferencePool.Acquire<VarVector4>();
                    variable.SetValue(value);
                }
                else if (value is Quaternion)
                {
                    variable = ReferencePool.Acquire<VarQuaternion>();
                    variable.SetValue(value);
                }
                else if (value is Color)
                {
                    variable = ReferencePool.Acquire<VarColor>();
                    variable.SetValue(value);
                }
                else if (value is Color32)
                {
                    variable = ReferencePool.Acquire<VarColor32>();
                    variable.SetValue(value);
                }
                else if (value is Rect)
                {
                    variable = ReferencePool.Acquire<VarRect>();
                    variable.SetValue(value);
                }
                else if (value is GameObject)
                {
                    variable = ReferencePool.Acquire<VarGameObject>();
                    variable.SetValue(value);
                }
                else if (value is Transform)
                {
                    variable = ReferencePool.Acquire<VarTransform>();
                    variable.SetValue(value);
                }
                else if (value is Material)
                {
                    variable = ReferencePool.Acquire<VarMaterial>();
                    variable.SetValue(value);
                }
                else if (value is Texture)
                {
                    variable = ReferencePool.Acquire<VarTexture>();
                    variable.SetValue(value);
                }
                else if (value is UnityEngine.Object)
                {
                    variable = ReferencePool.Acquire<VarUnityObject>();
                    variable.SetValue(value);
                }
                else if (value is System.DateTime)
                {
                    variable = ReferencePool.Acquire<VarDateTime>();
                    variable.SetValue(value);
                }
                else
                {
                    variable = ReferencePool.Acquire<VarObject>();
                    variable.SetValue(value);
                }

                return variable;
            }
        }
    }
}